import actionTypes from "./actionTypes"
import service from '../../service'
export function LoadRoleAction(payload){
  return{
    type:actionTypes.LOAD_ROLE_LIST,
    payload:payload,
  }
}
export function LoadRoleActionAsync(payload){
  return dispatch=>{
    return service.loadRoleList(payload).then((res)=>{
      dispatch(LoadRoleAction(res.data))
    })
  }
}
export function addRoleAction(payload){
  return{
    type:actionTypes.ADD_ROLE,
    payload:payload,
  }
}
export function addRoleActionAsync(payload){
  return dispatch=>{
    return service.addRole(payload).then((res)=>{
      dispatch(addRoleAction(res.data))
    })
  }
}
export function deleteRoleActionAsync(payload){
  return dispatch=>{
    return service.deleteRole(payload)
  }
}
export function updateRoleActionAsync(payload){
  return dispatch=>{
    return service.updateRole(payload)
  }
}
export function searchRoleActionAsync(payload){
  return dispatch=>{
    return service.searchRole(payload).then((res)=>{
      dispatch(LoadRoleAction(res.data))
    })
  }
}